<?php
include '../base/validateAgentLogin.php';
include '../class/MMysql.php';

$property_id= $_GET['property_id'];

$mysql = new MMysql();
$count1=$mysql->where(array("property_id"=>$property_id,"del_flag"=>0))->count('likes');
?>

<?php
include '../base/layout.php';
?>

<link href="../public/bootstrap-table/dist/bootstrap-table.css" rel="stylesheet" type="text/css" />
<script src="../public/bootstrap-table/dist/bootstrap-table.js"></script>

<style>
    .tablelist{
        /*margin-left: 15px;*/
        margin-right: 15px;
        margin-top: 20px;
    }
</style>

<body>

<?php
include '../base/agentheader.php';
?>

<section style="width: 100%;">

    <?php
    include '../base/agentsidemenu.php';
    ?>

    <aside class="content">

        <div style="margin-top: 20px;position: relative;">

            <div style="height: 20px;">

            </div>

            <span style="font-size: 30px;">
                Likes
            </span>

            <div class="agentmaincolor" style="width: 100%;height: 44px;position: relative;top:10px;">
                <span style="color:white;font-size: 20px;line-height: 44px;padding-left: 30px;">
                    A total of
                    <?php
                      echo $count1;
                    ?>
                    Likes
                </span>
            </div>

            <div class="tablelist">
                <table id="tradeList">

                </table>
            </div>

        </div>

    </aside>

</section>

</body>
</html>

<script type="text/javascript">
    $(function () {

        //得到查询的参数
        var queryParam = function (params) {
            var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                rows: params.limit,  //页面大小
                page: params.offset, //页码
                method:"list",
                <?php
                echo 'property_id:'.$property_id;
                ?>
            };
            return temp;
        };

        $('#tradeList').bootstrapTable({
            url: '../class/likes/likesfunction.php',     //请求后台的URL（*）
            method: 'GET',                      //请求方式（*）
            striped: true,                      //是否显示行间隔色
            cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: true,                   //是否显示分页（*）
            queryParams: queryParam,//传递参数（*）
            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
            pageNumber:1,                       //初始化加载第一页，默认第一页
            pageSize: 10,                       //每页的记录行数（*）
            pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
            clickToSelect: true,                //是否启用点击选中行
            uniqueId: "agent_number",                     //每一行的唯一标识，一般为主键列
//            showToggle:true,                    //是否显示详细视图和列表视图的切换按钮
            cardView: false,                    //是否显示详细视图
            detailView: false,
            //是否显示父子表
            columns: [{
                field: 'property_name',
                title: 'Name'
            }, {
                field: 'like_fullname',
                title: 'Full Name',
                align: 'center'
            }, {
                field: 'like_email',
                title: 'Email',
                align: 'center'
            },
                {
                    field: 'like_tel',
                    title: 'Tel',
                    align: 'center'
                }
                , {
                    field: 'like_wechat',
                    title: 'Wechat',
                    align: 'center'
                }
                , {
                    field: 'like_address',
                    title: 'Address',
                    align: 'center'
                }
                , {
                    field: 'operate',
                    title: 'Details',
                    align: 'center',
                    width:100,
                    clickToSelect: false,
                    formatter: operateFormatter,
                    events: {
                        'click .detail': function (e, value, row, index) {
                            // alert('删除 ' + JSON.stringify(row));

                        }}
                }],
            onDblClickRow:function(row,element,field){
                console.log( $('#tradeList').bootstrapTable('getSelections'));
            }
        });

        function operateFormatter(value, row, index) {
            return [
                '<a class="detail" style="color: rgb(92,172,196);" href="like_detail.php?like_id='+row['like_id']+'" data-agent_number='+row.agent_number+'  title="detail"> Click to view',
                '</a> '
            ].join('');
        }

    });
</script>